const utils = require('common.js');
//const utils = require('/storage/emulated/0/脚本/common.js');

var storage = storages.create("init");
var vedios= parseInt(storage.get("sD视界文章"));

var appname = "sD视界"
var cs= storage.get(appname+"初始");
var sx= storage.get(appname+"上限");

if(cs>=sx){
    toastLog(appname+"达到阅读上限");
    exit();
}else{
    storage.put(appname+"初始",cs+vedios);
    log(storage.get(appname+"初始"));
}

initParam={
    appName:"3D视界",
    totalNewsReaded : 0,//已经阅读的新闻条数
    totalNewsOneTime : 50,//一次性阅读多少条新闻
    loopTimeToFindNews : 5,//找了多少次新闻找不到会退出
    indexBtnText: "", //其他页面挑到首页的按钮文字，重要！
    indexFlagText:"关注",
    readallText:"展开全文",

    tanchuang:"imgClose",
    timeAwardText : "领取",//时段奖励关键字

    lastVedioText:"",//上一次新闻标题
    totalVedioReaded : 0,//已经阅读的新闻条数
    totalVedioOneTime : 50,//一次性阅读多少条新闻
    loopTimeToFindVedio : 20,//找了多少次新闻找不到会退出
    stanchuang:"弹窗id",
    indexBtnTexts: "首页", //其他页面挑到首页的按钮文字，重要！
    indexFlagTexts : "iv_like",//首页特有的标志id，重要！

    news:0,
    vedio:vedios,
    hdsj:7,
    newssx:"首页",
    vediosx:"首页",
};

utils.wakeUp(); 
utils.clears();
app.launchApp(initParam.appName);
sleep(7000);
utils.UITextBoundsClick("我知道了");
utils.UITextBoundsClick("跳过");
utils.UITextBoundsClick("取消");
var flag=false;

var gx1 = text("免费领取梦想池").findOnce()
if(gx1){
    toastLog("领取")
    click(gx1.bounds().centerX(),gx1.bounds().centerY());
    sleep(5000)
    var gx1 = text("去完成").findOnce()
    if(gx1){
        toastLog("观看广告")
        click(gx1.bounds().centerX(),gx1.bounds().centerY());
        sleep(60000)
        var gx1 = text("关闭").findOnce()
        if(gx1){
            toastLog("关闭广告")
            click(gx1.bounds().centerX(),gx1.bounds().centerY());
            sleep(3000)
        }
    }
}

var thisEle = text("点击收取").findOnce();
if (thisEle) {
        toastLog("收取")
        click(thisEle.bounds().centerX(),thisEle.bounds().centerY());
        sleep(62000)
        var thisEle = text("关闭收取").findOnce();
        if (thisEle) {
            toastLog("收取")
            click(thisEle.bounds().centerX(),thisEle.bounds().centerY());
            sleep(2000)
        }
}

var thisEle = desc("点击收取").findOnce();
if (thisEle) {
        toastLog("收取")
        click(thisEle.bounds().centerX(),thisEle.bounds().centerY());
        sleep(62000)
        var thisEle = desc("关闭收取").findOnce();
        if (thisEle) {
            toastLog("收取")
            click(thisEle.bounds().centerX(),thisEle.bounds().centerY());
            sleep(2000)
        }
        var thisEle = text("关闭收取").findOnce();
        if (thisEle) {
            toastLog("收取")
            click(thisEle.bounds().centerX(),thisEle.bounds().centerY());
            sleep(2000)
        }
}


var gx1 = text("免费领取梦想池").findOnce()
if(gx1){
    toastLog("领取")
    click(gx1.bounds().centerX(),gx1.bounds().centerY());
    sleep(5000)
    var gx1 = text("去完成").findOnce()
    if(gx1){
        toastLog("观看广告")
        click(gx1.bounds().centerX(),gx1.bounds().centerY());
        sleep(60000)
        var gx1 = text("关闭").findOnce()
        if(gx1){
            toastLog("关闭广告")
            click(gx1.bounds().centerX(),gx1.bounds().centerY());
            sleep(3000)
        }
    }
}
//阅读新闻
function readvedios(seconds){

        //滑动阅读新闻
        for(var i = 0 ;i < 1 ;i++){
            var tt = random(10000,20000);
            sleep(tt);
        }

}
